<!DOCTYPE html>
<html xmlns:th="www.thymeleaf.org">
<meta charset="UTF-8">
<head th:replace="back/index::ph('新增作业')"></head>
<body>
	<header th:replace="back/index::header"></header>
	<main>
		<div class="content">
			<fieldset>
				<legend><a href="/">首页</a> >> 新增作业</legend>
				<div class="form">
				班级：<input v-model="clsSn" maxlength="20"><br>
				<choose items="hwctask/course/find" model="courseId" label="课程"></choose><br>
				时间：<input v-model="finishAt" type="datetime"><br>
				作业：<input v-model="name"><br>
				描述：<input v-model="intro"><br>
				<button @click="save">添加</button>
				</div>
			</fieldset>
		</div>
	</main>
	<footer th:replace="back/index::footer"></footer>
</body>
<script type="text/javascript">
	var v = new Vue({
		el : "main",
		data : {
			clsSn:"", 
			name:"", 
			courseId:"", 
			finishAt:new Date().format("yyyy-MM-dd"), 
			intro:""
		},
		methods : {
			save(){
				var p = usp(this.$data, "courseId", "course.id");
				axios.post("hwctask/task/save", p).then(res=>{
					if(res.data.code==1){
						location.href = "go_task_query";
					} else {
						alert(res.data.msg);
						console.info(res.data);
					}
				});
			}
		}
	});


</script>
</html>